package com.example.freshfoodproject.service.impl;

import com.example.freshfoodproject.entry.Goods;
import com.example.freshfoodproject.entry.User;
import com.example.freshfoodproject.mapper.UserMapper;
import com.example.freshfoodproject.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public boolean login(User user) {
        return userMapper.selectUsernameAndPassword(user)>0?true:false;
    }

    @Override
    public boolean register(User user) {
        return userMapper.insertUser(user)==1?true:false;
    }

    @Override
    public User findByusername(String username) {
        return userMapper.selectByUsername(username).size()==1?userMapper.selectByUsername(username).get(0):new User();
    }

    @Override
    public boolean findUsername(User user) {
        return userMapper.selectUsername(user)>0?true:false;
    }


}
